<script setup lang="ts">
import { useRoute,useRouter } from 'vue-router'
import { onMounted, ref } from 'vue'
import Request from '@/api/axios'
import { message } from 'ant-design-vue'
import dayjs from 'dayjs'
import type { Contest } from '@/types'
import { HttpStatusCode } from 'axios'
const router = useRouter()
const id = useRoute().params.id
const contest = ref<Contest>()
onMounted(async () => {
    await Request.get({
        url: `/contest/${id}`
    })
        .then((res) => {
            if(res.code === HttpStatusCode.NotFound){
                router.push({name : 'notfound'})
                return
            }
            contest.value = res.info})
        .catch((e) => {
            message.error("出错啦")
            console.log(e)
        })
        .finally(() => {})
})
</script>

<template>
    <br />
    <span class="text-xl"> {{ contest?.title }}</span>
    <br />
    <a-typography-text>
        {{ contest?.introduction }}
    </a-typography-text>
    <br />
    时间 {{ dayjs(contest?.begin_at).format('YYYY-MM-DD HH:mm:ss') }} ->
    {{ dayjs(contest?.begin_at).add(contest?.duration ?? 0, 'minute').format('YYYY-MM-DD HH:mm:ss') }}
    <br />
    {{ contest?.createdBy }}
    {{ contest?.isPrivate }}
    {{ contest?.userID }}
    {{ contest?.submission }}
    {{ contest?.accept }}
</template>

<style scoped></style>
